package com.hziee.mail.controller;

import com.hziee.mail.service.GoodDetailService;
import com.hziee.mail.service.OrderService;
import com.hziee.mail.util.FormatReturn;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;

/**
 * @author ZX
 */
@RestController
@RequestMapping("/good_detail")
public class GoodDetailController extends FormatReturn {

    @Autowired
    private GoodDetailService goodDetailService;

    @Autowired
    private OrderService orderService;

    @GetMapping("/show_detail")
    public String findGoodDetail(HttpServletResponse response, String goodId) {
        HashMap<String, Object> map = goodDetailService.findGoodDetail(goodId);
        return ajaxReturn(response, map);
    }

    @GetMapping("/find_amount")
    public String findAmount(HttpServletResponse response, String goodsId) {
        return ajaxReturn(response, 1, "success", orderService.findAmount(goodsId));
    }

}
